let io = require('socket.io')();
let clientSocket = require('./common/client_socket')
//**********************管理端************************** */
let adminDashboard = require('./views/dashboard/index.js')
let adminInstall = require('./views/install/index.js')
let adminLogin = require('./views/login/login.js');
let adminDepartment = require('./views/department/index.js')
let adminEquipment = require('./views/equipment/index.js');
let adminNotice = require('./views/notice/index.js')(io);
let backendUploadApi = require('./api/backend/upload');
let adminEmployees = require('./views/employees/index.js')(io);
let adminSetting = require('./views/setting/index.js');
let verifyLogin = require('./middleware/verify_login');
let verifyInstall  = require('./middleware/verify_install');
let adminProfile   =require('./views/person/index.js')



//************************客户端 ****************** */
let clientIndexAPI = require('./api/client/index')(io);
let verification_client_token = require('./middleware/verification_client_token');
let registerClientAPI = require('./api/client/register')
let versionClientAPI = require('./api/client/version')

exports.route = function (app) {

  //************************客户端 ****************** */
  app.use('/api/client/register', registerClientAPI);
  app.use('/api/client/version', versionClientAPI);
  app.use(verification_client_token);
  app.use('/api/client', clientIndexAPI);


  app.use(verifyInstall); //验证系统是否已安装
  app.use('/install', adminInstall) //安装
  app.use('/login', adminLogin) //登录
  app.use(verifyLogin); //登录验证
  app.use('/', adminDashboard) //dashboard 

  app.use('/department', adminDepartment); //部门管理界面
  app.use('/equipment', adminEquipment); //设备管理
  app.use('/notice', adminNotice)
  app.use('/api/upload', backendUploadApi);
  app.use('/employees', adminEmployees); //员工管理
  app.use('/setting', adminSetting); //系统设置
  app.use('/profile',adminProfile); //个人中心










  //*********************socket.io 操作 ***********************/
  app.io = io;
  io.on('connection', function (socket) {
    clientSocket.clientSocket(socket)
  });
}